{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Bernstein Vazirani Algorithm  \n",
    "  \n",
    "Problem: Given a \"secret\" $n$-bit string $s$ and an oracle that implements function $f:\\{0,1\\}^{n}\\rightarrow\\{0,1\\}$ , find $s$.  \n",
    "Bernstein and Vazirani considered $f(x) = x\\cdot s \\,\\,{\\rm mod}\\,\\, 2 = (\\sum\\limits_{i=0}^{n-1} x_i s_i)\\,\\,{\\rm mod} \\,\\,2$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Classical Solution  \n",
    "In binary format $s = s_0 s_1 \\cdots s_{n-1}$ where $s_i = \\{0,1\\}$  \n",
    "By definition\n",
    "$f(0\\cdots01_{i}0\\cdots0) = s_{i}$ and with n oracle calls we can determine the \"secret\" bit string $s$  \n",
    "\n",
    "$f(1_{0} 0_{1} \\cdots 0_{n-1}) = s_{0}$   \n",
    "$f(0_{0} 1_{1} \\cdots 0_{n-1}) = s_{1}$   \n",
    "$\\vdots$   \n",
    "$f(0_{0} 0_{1} \\cdots 1_{n-1}) = s_{n-1}$   \n",
    "\n",
    "Finding $s$ requires $n$ oracle calls classically"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Quantum Solution  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Input state $|0\\rangle^{\\otimes n}$\n",
    "* Prepare an equal superposition of all possible bit strings $|+\\rangle^{\\otimes n} = \\frac{1}{\\sqrt{2^n}}\\sum\\limits_{x\\in\\{0,1\\}^{n}}|x\\rangle$\n",
    "* Apply a quantum oracle $U_{f(x)}\\rightarrow$ $\\frac{1}{\\sqrt{2^n}}\\sum\\limits_{x\\in\\{0,1\\}^{n}}(-1)^{f(x)}|x\\rangle = \\frac{1}{\\sqrt{2}}(|0\\rangle + (-1)^{s_0}|1\\rangle)\\otimes\\cdots\\otimes\\frac{1}{\\sqrt{2}}(|0\\rangle + (-1)^{s_{n-1}}|1\\rangle)$\n",
    "* Apply $n$ Hadamard gates to return to the computational basis\n",
    "* Read out the final state in the computational basis = the secret string $s$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# general imports\n",
    "import boto3\n",
    "import numpy as np\n",
    "import math\n",
    "import matplotlib.pyplot as plt\n",
    "# magic word for producing visualizations in notebook\n",
    "%matplotlib inline\n",
    "import string\n",
    "import time\n",
    "from datetime import datetime\n",
    "# import logging\n",
    "import logging"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Braket SDK imports  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from braket.circuits import Circuit, Gate, Instruction, circuit, Observable\n",
    "from braket.aws import AwsDevice, AwsQuantumTask\n",
    "from braket.devices import LocalSimulator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Set up Braket simulator "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# set up the device to be the managed simulator\n",
    "# device = AwsDevice(\"arn:aws:braket:::device/quantum-simulator/amazon/sv1\")\n",
    "\n",
    "# set up the device to be the Rigetti quantum computer\n",
    "# device = AwsDevice(\"arn:aws:braket:::device/qpu/rigetti/Aspen-8\")\n",
    "\n",
    "# set up the device to be the IonQ quantum computer\n",
    "# device = AwsDevice(\"arn:aws:braket:::device/qpu/ionq/ionQdevice\")\n",
    "\n",
    "# set up the device to be the local simulator\n",
    "#device = LocalSimulator()\n",
    "\n",
    "# set up S3 bucket (where results are stored)\n",
    "# aws_account_id = boto3.client(\"sts\").get_caller_identity()[\"Account\"]\n",
    "my_bucket = f\"amazon-braket-xxx\" # f\"amazon-braket-{aws_account_id}\"the name of the bucket\n",
    "my_prefix = \"bv-output\" # the name of the folder in the bucket\n",
    "s3_folder = (my_bucket, my_prefix)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Define quantum oracle circuit for $U_{f(x)}$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "def oracleBV(s):\n",
    "    ## s is the \"secret\" string\n",
    "    nQbts = len(s) + 1\n",
    "    \n",
    "    ## initilize the oracle ancila in |->\n",
    "    oracle_circ = Circuit().ry(nQbts-1,-0.5*np.pi)\n",
    "    \n",
    "    ## add a Cx gate between qubit i and ancilla if s_i = 1 \n",
    "    for ind in range(nQbts-1):\n",
    "        if s[ind] == '1':\n",
    "            oracle_circ.cnot(control=ind, target=nQbts-1)\n",
    "    ## rotate the ancilla qubit back to the Z basis and flip it        \n",
    "    oracle_circ.h(nQbts-1).x(nQbts-1)\n",
    "    return oracle_circ"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "T  : |    0    |1|2|3|4|5|\n",
      "                          \n",
      "q1 : -----------C---------\n",
      "                |         \n",
      "q3 : -----------|-C-------\n",
      "                | |       \n",
      "q4 : -----------|-|-C-----\n",
      "                | | |     \n",
      "q5 : -Ry(-1.57)-X-X-X-H-X-\n",
      "\n",
      "T  : |    0    |1|2|3|4|5|\n"
     ]
    }
   ],
   "source": [
    "s = '01011'\n",
    "print (oracleBV(s))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Bernstein Vazirani Circuit  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "T   : |    0    | 1 |2|3|4|5|6|7|8|9|10|11|\n",
      "                                           \n",
      "q0  : -H---------C---H---------------------\n",
      "                 |                         \n",
      "q1  : -H---------|---C-H-------------------\n",
      "                 |   |                     \n",
      "q2  : -H---------|-H-|---------------------\n",
      "                 |   |                     \n",
      "q3  : -H---------|---|-C-H-----------------\n",
      "                 |   | |                   \n",
      "q4  : -H---------|---|-|-C-H---------------\n",
      "                 |   | | |                 \n",
      "q5  : -H---------|---|-|-|-C-H-------------\n",
      "                 |   | | | |               \n",
      "q6  : -H---------|---|-|-|-|-C-H-----------\n",
      "                 |   | | | | |             \n",
      "q7  : -H---------|---|-|-|-|-|-C-H---------\n",
      "                 |   | | | | | |           \n",
      "q8  : -H---------|---|-|-|-|-|-|-C-H-------\n",
      "                 |   | | | | | | |         \n",
      "q9  : -H---------|---|-|-|-|-|-|-|-C-H-----\n",
      "                 |   | | | | | | | |       \n",
      "q10 : -Ry(-1.57)-X---X-X-X-X-X-X-X-X-H--X--\n",
      "\n",
      "T   : |    0    | 1 |2|3|4|5|6|7|8|9|10|11|\n"
     ]
    }
   ],
   "source": [
    "## define the secret string\n",
    "s = '1101111111'\n",
    "## Initialize the BV circuit\n",
    "BV_circuit = Circuit()\n",
    "\n",
    "for ind in range(len(s)):\n",
    "    BV_circuit.h(ind)\n",
    "\n",
    "## Add the oracle to the circuit\n",
    "BV_circuit.add_circuit(oracleBV(s))\n",
    "\n",
    "## Rotate back to the computational basis\n",
    "for ind in range(len(s)):\n",
    "    BV_circuit.h(ind)\n",
    "\n",
    "## Print the BV circuit\n",
    "print(BV_circuit)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Set up SV1 backend  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# set up the device to be the managed simulator\n",
    "device = AwsDevice(\"arn:aws:braket:::device/quantum-simulator/amazon/sv1\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Counter({'11011111110': 100})\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEGCAYAAACKB4k+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/A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oxcFWSKxmExhl78R3SHvmTVGmR6O5z+GFVVZI1wIlVtbrvujRZ9nguU9JYPQv4uyRh8G6FN/ZcjyaQIwVJUuM1BUlSYyhIkhpDQZLUGAqSpMZQkCQ1/w9kTOK8ZcHx3QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Create a quantum task to run the BV circuit\n",
    "task_BV = device.run(BV_circuit, s3_folder, shots=100)\n",
    "\n",
    "## Get results of task\n",
    "results = task_BV.result()\n",
    "\n",
    "## Get measurement counts\n",
    "counts = results.measurement_counts\n",
    "\n",
    "# print counts\n",
    "print(counts)\n",
    "\n",
    "# plot using Counter\n",
    "plt.bar(counts.keys(), counts.values());\n",
    "plt.xlabel('bitstrings');\n",
    "plt.ylabel('counts');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Set up IonQ backend   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "# set up the device to be the IonQ quantum computer\n",
    "device = AwsDevice(\"arn:aws:braket:::device/qpu/ionq/ionQdevice\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Counter({'11011111110': 99, '11001111110': 1})\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEGCAYAAACKB4k+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAQXUlEQVR4nO3de7BdZX3G8e8j0SooUygHDGCNdTJavODliKLV0SLFamuoFYstmipTOlMV6WU60c5Upy0tttYWrzMpC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12hoIEG4HVSa4G9mfwe9fD1gJXJzkHeBJwaZKrGPSg+VdDy/zbthvNu+gU4I+SXAosB7Zdmno+cFWSKxmExukP4DukHfKRVGmR6N5z+EFVVZLjgVdW1aq+69J02eG1TEkT9XTg3d0PJd0JvLbnejSFPFOQJDXeU5AkNYaCJKkxFCRJjaEgSWoMBUlS8/+rJBON64qnmAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Create a quantum task to run the BV circuit on IonQ\n",
    "ionq_task_BV = device.run(BV_circuit, s3_folder, shots=100)\n",
    "\n",
    "## Get results of task\n",
    "ionq_results = ionq_task_BV.result()\n",
    "\n",
    "## Get measurement counts\n",
    "ionq_counts = ionq_results.measurement_counts\n",
    "\n",
    "# print counts\n",
    "print(ionq_counts)\n",
    "\n",
    "# plot using Counter\n",
    "plt.bar(ionq_counts.keys(), ionq_counts.values());\n",
    "plt.xlabel('bitstrings');\n",
    "plt.ylabel('counts');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Set up Rigetti backend  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# set up the device to be the Rigetti quantum computer\n",
    "device = AwsDevice(\"arn:aws:braket:::device/qpu/rigetti/Aspen-8\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Counter({'00001101011': 2, '00001111101': 2, '00000011001': 2, '00011100101': 2, '10101100101': 2, '10111101110': 2, '00001001000': 1, '00110101100': 1, '11101000010': 1, '10010010011': 1, '11110000110': 1, '00100101000': 1, '01111001000': 1, '10111000011': 1, '11011100101': 1, '01101100010': 1, '01100100000': 1, '10110110100': 1, '01011101010': 1, '00000110111': 1, '00111100101': 1, '10100001011': 1, '10101010011': 1, '00001010110': 1, '10111101010': 1, '10100001100': 1, '10101111010': 1, '11011001101': 1, '11110111010': 1, '01001111111': 1, '10110111111': 1, '10001110101': 1, '10110111011': 1, '10111011011': 1, '10111001110': 1, '10001011010': 1, '01000000010': 1, '00010100111': 1, '00010001111': 1, '10110100011': 1, '11100000011': 1, '10101011110': 1, '10111011001': 1, '00000101110': 1, '00010001101': 1, '01001000001': 1, '11101001010': 1, '00011001000': 1, '10010001111': 1, '00100000101': 1, '00000001000': 1, '10110100101': 1, '10100000011': 1, '00011001010': 1, '00010001001': 1, '01101101010': 1, '10101000010': 1, '01110101101': 1, '01101010110': 1, '00010100000': 1, '11001001000': 1, '10110111101': 1, '10111110111': 1, '10101111001': 1, '00000111101': 1, '10101001101': 1, '01101000011': 1, '00001101001': 1, '01101001100': 1, '10011000011': 1, '00101100010': 1, '00110011111': 1, '00010101011': 1, '00011001011': 1, '10011100100': 1, '11111000111': 1, '11001001010': 1, '11100101111': 1, '01011001100': 1, '00110111111': 1, '00000000100': 1, '11010100000': 1, '10100010001': 1, '11001001100': 1, '00101000101': 1, '01111000111': 1, '10000100010': 1, '11100110110': 1, '10011000001': 1, '00100111101': 1, '10010101110': 1, '10111100111': 1, '11001110101': 1, '00111101101': 1})\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZsAAAEGCAYAAACzYDhlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAaSUlEQVR4nO3df/BldX3f8eeL3UWF4I/A+iPAuoxDU4kRYr5BLSZCpzqL0ZKkJoH4qxq7NZU0Nm2mNJ1qJmlaO6Y/iBLp1hBqEqVtFMPEVbAZK1EHw2IRQSWz3WBZ14YVEFBA+LLv/nHOdc9e7r3fuz8++/2R52Pmzj3n8+Oc9z33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nuRm4F8C/3rQ5mOjEwQO0duAX07y53SXhB8N0Z0L3Jzkf9Mlo0sPYx3SUeOpz9IK1P9O56GqqiQXAhdV1QXLHZd0qGaOD0taNj8MvCfJ6N8a37TM8UiHxT0bSVJzHrORJDVnspEkNWeykSQ1Z7KRJDVnspEkNff/AZkgtf4cDj9fAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Create a quantum task to run the BV circuit on Rigetti\n",
    "rigetti_task_BV = device.run(BV_circuit, s3_folder, shots=100)\n",
    "\n",
    "## Get results of task\n",
    "rigetti_results = rigetti_task_BV.result()\n",
    "\n",
    "## Get measurement counts\n",
    "rigetti_counts = rigetti_results.measurement_counts\n",
    "\n",
    "# print counts\n",
    "print(rigetti_counts)\n",
    "\n",
    "# plot using Counter\n",
    "plt.bar(rigetti_counts.keys(), rigetti_counts.values());\n",
    "plt.xlabel('bitstrings');\n",
    "plt.ylabel('counts');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "conda_braket",
   "language": "python",
   "name": "conda_braket"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
